use xiaohao_ar::vec_ar::*;
// 1.
#[test]
fn intersect_test() {
    let v1 = vec![1, 2, 2, 1];
    let mut v2 = vec![2, 2];
    assert_eq!(vec![2, 2], intersect(v1, &mut v2));
}
// 1.2
#[test]
fn intersect_v2_test() {
    let v1 = vec![1, 3, 4, 4, 13];
    let mut v2 = vec![1, 4, 9, 10];
    assert_eq!(vec![1, 4], intersect_v2(v1, &mut v2));
}

// 2.
#[test]
fn longest_common_prefix_test() {
    let s1 = vec!["flower", "flow", "flight"];
    assert_eq!("fl", longest_common_prefix(s1));
    let s2 = vec!["dog", "racecar", "car"];
    assert_eq!("", longest_common_prefix(s2));
}

// 3.
#[test]
fn max_profit_test() {
    let prices = vec![7, 1, 5, 3, 6, 4];
    assert_eq!(7, max_profit(prices));
    let prices = vec![1, 2, 3, 4, 5];
    assert_eq!(4, max_profit(prices));
}

// 4.
#[test]
fn rotate_test() {
    let mut v1 = vec![1, 2, 3, 4, 5, 6, 7];
    assert_eq!(vec![5, 6, 7, 1, 2, 3, 4], rotate(&mut v1, 3));
}

// 5.
#[test]
fn remove_element_test() {
    let mut v1 = vec![3, 3, 3, 3];
    assert_eq!(vec![3], remove_element(&mut v1, 3));
}

// 6.
#[test]
fn plus_one_test() {
    let mut v1 = vec![1, 2, 3];
    assert_eq!(vec![1, 2, 4], plus_one(&mut v1));
    let mut v2 = vec![1, 9, 9];
    assert_eq!(vec![2, 0, 0], plus_one(&mut v2));
    let mut v3 = vec![9, 9];
    assert_eq!(vec![1, 0, 0], plus_one(&mut v3));
}

// 7.
#[test]
fn two_sum_test() {
    let v1 = vec![2, 7, 11, 15];
    assert_eq!(vec![0, 1], two_sum(v1, 9));
}
